package com.ruoyi.service.account.enums.company;

import com.ruoyi.common.core.enums.YesNoEnum;
import lombok.Getter;

/**
 * <p>
 * 作用：变动类型
 * </p>
 *
 * @author Zane
 * @since 2025-10-05 21:15
 */
@Getter
public enum ChangeTypeEnum {
  ADD("YC", "预存", 1, YesNoEnum.NO, "公司账户充值"),
  LOCKED("SD", "锁定", 0, YesNoEnum.YES, "项目发布锁定"),
  RELEASE("JS", "解锁", 0, YesNoEnum.YES, "项目结算解除锁定"),
  PAY("PAY", "扣款", -1, YesNoEnum.NO, "公司账户支出")
  ;
  /**
   * 编码
   */
  private final String code;

  /**
   * 输入输出标识  锁定 0 ,入账 1, 出账 -1
   */
  private final Integer ioFlag;
  /**
   * 锁定操作标记 否 0 是 1
   */
  private final YesNoEnum lockedFlag;
  /**
   * 名称
   */
  private final String name;
  /**
   * 描述
   */
  private final String desc;

  ChangeTypeEnum(String code, String name, Integer ioFlag, YesNoEnum lockedFlag, String desc) {
    this.code = code;
    this.name = name;
    this.ioFlag = ioFlag;
    this.lockedFlag = lockedFlag;
    this.desc = desc;
  }

  public boolean eqCode(String code) {
    return this.code.equals(code);
  }

  public static ChangeTypeEnum valueOfCode(String changeType) {
    for (ChangeTypeEnum value : ChangeTypeEnum.values()) {
      if (value.eqCode(changeType)) {
        return value;
      }
    }
    throw new IllegalArgumentException("变动类型不存在");
  }
}
